package wikitools.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import wikitools.model.Note;
import wikitools.model.TextBase;
import wikitools.model.TextBaseFactory;
import wikitools.util.XMLUtil;

public class GetNote extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) {
        String noteid = request.getParameter("noteid");
        TextBase db = TextBaseFactory.getTextBase();
        try{
            Note x = db.getNoteById(noteid);
            response.setStatus(200);
            ServletUtil.writeXML(XMLUtil.toXML(x), response);
        }catch(Exception e) {
            System.err.println("<><><><>Error in getting a Note " + noteid);
        }
        
    }
    
    

}
